package com.fwzc.giuseppe.adapter;

import java.util.ArrayList;
import com.fwzc.giuseppe.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class GrideAdapter extends BaseAdapter{
	private ArrayList<String> datas;
	private Context context;

	public GrideAdapter(Context context, ArrayList<String> datas) {
		this.datas = datas;
		this.context = context;
	}

	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int position) {
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	private class ViewHolder{
		ImageView image;
		TextView name;
		TextView number;
		Button trolley;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.clothes_item, null);
			holder.image = (ImageView)convertView.findViewById(R.id.image);
			holder.name = (TextView)convertView.findViewById(R.id.name);
			holder.number = (TextView)convertView.findViewById(R.id.number);
			holder.trolley = (Button)convertView.findViewById(R.id.add_trolley);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder)convertView.getTag();
		}
		return convertView;
	}

}
